layui.use(['form','jquery'],function () {
    var form = layui.form,
        $ = layui.jquery;

    /**
     *注册普通用户
     */
    form.on("submit(register)",function(data) {
        var index = top.layer.msg('注册中，请稍候', {icon: 16, time: false, shade: 0.8});
        var obj = data.field;
        console.log(obj)
        /**
         * 请求后台
         */
        $.ajax({
            type: 'POST',
            url: '/consumerController/add',
            data: JSON.stringify(obj),
            dataType: 'json',
            contentType: 'application/json',
            success: function (data) {
                /**
                 * 添加成功后回调
                 **/
                setTimeout(function () {
                    top.layer.close(index);
                    top.layer.msg(data.msg);
                    // layer.closeAll("iframe");
                    // //刷新父页面
                    // parent.location.reload();
                }, 500);
                return false;
            }
        });
    });
});